<template>
    <el-select v-model="currentValue" placeholder="请选择分类" clearable @change="handleChange">
        <el-option v-for="(item, index) in categoryList" :key="index" :label="item.title" :value="item.id"
            :disabled="item.disabled"></el-option>
    </el-select>
</template>
<script setup>
import { getDecorationCategory } from '@/api/article'
import { ref, watch } from 'vue'

const props = defineProps({
    modelValue: {
        type: [Number, String],
        default: ''
    }
})
const emit = defineEmits(['update:modelValue'])
const categoryList = ref([])
const currentValue = ref(props.modelValue)

onMounted(async () => {
    let { list } = await getDecorationCategory()
    categoryList.value = list
})
watch(() => props.modelValue, (newVal) => {
    currentValue.value = newVal
}, { immediate: true })
const handleChange = (val) => {
    emit('update:modelValue', val)
}
</script>
<style></style>